﻿using System;

namespace Simple3DRedactor.Domain
{
    [Serializable]
    public sealed class Sphere : Geometry
    {
        public Sphere()
        {
            Name = "Sphere";
            Radius = 1.0f;
            Slices = 50;
            Stacks = 50;
        }

        private float _radius;
        public float Radius
        {
            get { return _radius; }
            set
            {
                if (Math.Abs(_radius - value) > float.Epsilon)
                {
                    _radius = value;
                    OnChange();
                }
            }
        }

        private int _slices;
        public int Slices
        {
            get { return _slices; }
            set
            {
                if (_slices != value)
                {
                    _slices = value;
                    OnChange();
                }
            }
        }

        private int _stacks;
        public int Stacks
        {
            get { return _stacks; }
            set
            {
                if (_stacks != value)
                {
                    _stacks = value;
                    OnChange();
                }
            }
        }

        public override TV CreateView<TV>(IObjectViewFactory<TV> factory)
        {
            return factory.Create(this);
        }
    }
}
